package com.example.hcbmsm.controller;

import com.example.hcbmsm.domain.Drug;
import com.example.hcbmsm.service.DrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Xinghm
 * @version 1.0
 * @since 2024/11/1 16:35
 */
@RestController
@CrossOrigin
@RequestMapping("/drug")
public class DrugController {
    @Autowired
    private DrugService drugService;

    @GetMapping("/list")
    public Map list() {
        return drugService.list();
    }

    @GetMapping("/listByPage")
    public Map listByPage(String drugName, int page, int limit) {
        return drugService.listByPage(drugName, page, limit);
    }

    @PostMapping("/add")
    public Map add(@RequestBody Drug drug) {
        return drugService.add(drug);
    }

    @PostMapping("/renew")
    public Map renew(@RequestBody Drug drug) {
        return drugService.renew(drug);
    }

    @PostMapping("/remove")
    public Map remove(Long drugId) {
        return drugService.remove(drugId);
    }
}
